//
//  XLModifyPSAdapter.m
//  industry
//
//  Created by xl on 2020/12/10.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLModifyPSAdapter.h"
#import "XLTitleTextFieldCell.h"

NSString *const XLModifyPSAdapterOldPS = @"XLModifyPSAdapterOldPS";
NSString *const XLModifyPSAdapterNewPS = @"XLModifyPSAdapterNewPS";
NSString *const XLModifyPSAdapterNewAgainPS = @"XLModifyPSAdapterNewAgainPS";


@implementation XLModifyPSAdapter

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.getAdapterArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 90.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row > self.getAdapterArray.count - 1) {
        return [XLTableViewCell new];
    }
    id data = self.getAdapterArray[indexPath.row];
    static NSString *cellIdentifierId = @"XLTitleTextFieldCell";
    XLTitleTextFieldCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifierId];
    if (!cell) {
        cell = [[XLTitleTextFieldCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifierId];
    }
    [cell setCurrentSecurity:YES];
    if ([data isEqualToString:XLModifyPSAdapterOldPS]) {
        [cell loadCellData:@"旧密码" content:self.oldPs placeholder:@"请输入您的旧密码"];
    } else if ([data isEqualToString:XLModifyPSAdapterNewPS]) {
        [cell loadCellData:@"请输入您的新密码" content:self.ps placeholder:@"请输入您的新密码"];
    } else if ([data isEqualToString:XLModifyPSAdapterNewAgainPS]) {
        [cell loadCellData:@"请确认您的新密码" content:self.rePs placeholder:@"请再次输入您的新密码"];
    }
    cell.TextFieldBlock = ^(NSString *content) {
         if ([data isEqualToString:XLModifyPSAdapterOldPS]) {
             self.oldPs = content;
         } else if ([data isEqualToString:XLModifyPSAdapterNewPS]) {
             self.ps = content;
         } else if ([data isEqualToString:XLModifyPSAdapterNewAgainPS]) {
             self.rePs = content;
         }
    };
    return cell;
}


@end
